# a CMake that works with pylon cam and OpenCV project
# created 05/11/14
# author: Shawn Le

cmake_minimum_required(VERSION 2.8)
project( ChkbrdTrackPoseest ) 

set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} 
												"D:/Program Files/Basler/pylon 4"
												"D:/Documents and Settings/SonLe/My Documents/SOFTs/OpenCV-2.4.2/opencv/build/"
)												

#set(OpenCV_DIR "D:/opencv/build")
set(OpenCV_DIR "D:/Documents and Settings/SonLe/My Documents/SOFTs/OpenCV-2.4.2/opencv/build/")

# find_package calls CMake module, if I don't use find_package, I can use target_link_libraries & link_directories combination instead
find_package( OpenCV REQUIRED core highgui imgproc objdetect calib3d features2d ml flann nonfree video contrib gpu legacy photo ts stitching) # 


# pointing to cmake module
set(Pylon_DIR "D:/Program Files/Basler/pylon 4")
find_package( Pylon REQUIRED 
										Pylon1394_MD_VC100_TL 
										PylonBase_MD_VC100 
										PylonBootstrapper 
										PylonCLSer_MD_VC100_TL
										PylonGigE_MD_VC100_TL 
										PylonGUI_MD_VC100 
										PylonUsb_MD_VC100_TL 
										PylonUtility_MD_VC100
) # 


# check finding
IF (OpenCV_FOUND)
message("OpenCV is found\n")
ELSE (OpenCV_FOUND)
message("OpenCV is NOT found\n")
ENDIF (OpenCV_FOUND)


IF (PYLON_FOUND)
message("Pylon is found\n")
ENDIF (PYLON_FOUND)


include_directories(		${OpenCV_INCLUDE_DIRS} 
										${PYLON_INCLUDE_DIRS}
)

# NO  NEED  AFTER CALLING find_package, it depends on specific library's CMake module
#link_directories(   ${OpenCV_LIB_DIR} 
#								${PYLON_LIBRARIES}
#								"D:/Program Files/Basler/pylon 4/pylonc/lib/Win32"
#								"D:/Program Files/Basler/pylon 4/genicam/library/cpp/lib/win32_i86"
#)


message("OpenCV_LIB_DIR = ${OpenCV_LIB_DIR}")
message("OpenCV_INCLUDE_DIRS = ${OpenCV_INCLUDE_DIRS}")
message("OpenCV_DIR = ${OpenCV_DIR}")
message("OpenCV_LIBS = ${OpenCV_LIBS}")
message("PYLON_LIBRARIES = ${PYLON_LIBRARIES}")

add_executable( ChkbrdTrackPoseest main.cpp VSKptTracker.cpp MatWork.cpp ObjectDetector.cpp PoseEstimator.cpp ZhangPoseEstimator.cpp PylonGrabber.cpp)


# here only put the library names without path, coz' path is given in link_directories
target_link_libraries( ChkbrdTrackPoseest ${OpenCV_LIBS} ${PYLON_LIBRARIES})

